﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Way.Bus.Controllers;
using System.Data;
using Way.Bus.Model;
using Way.Bus.WMS.Model;
using Way.EAP.DataAccess.Entity;

namespace Way.Bus.WMS.ST.Controllers
{
    public class ST_ExcelDCController : ExcelDCController
    {
        protected override string GetZjsql(string sql, IHierarchicalEntityView v, string sqlzi,EntityBase eb)
        {
            IEntityBase ieb = eb;
            IHierarchicalEntityView[] vs= ieb.GetChildEntityList();
            foreach (IHierarchicalEntityView vvv in vs)
            {
                string tn = vvv.ChildEntity.ToString();
                if (tn.EndsWith("Sequence"))
                {
                    string allsql = "select a.*,b.SEQUENCECODE ,CASE WHEN b.SEQUENCECODE is null THEN  a.num ELSE '1' END as 'SJSL'   from (" + sqlzi + ") a left join " + tn + " b on a.id=b.";
                    if (vvv.ChildEntity is InSequence)
                        allsql += "InOrderMATERIALID";
                    if (vvv.ChildEntity is OutInSequence)
                        allsql += "OutOrderMATERIALID";
                    return allsql;
                }
            }
            return sqlzi;
        }

        protected override Dictionary<string, string> Update_DC_Part_Field(Dictionary<string, string> dicColumns)
        {
            dicColumns.Add("SJSL", "实际数量");
            return dicColumns;
        }
    }
}
